using System;
using System.Collections.Generic;

namespace IGlobalist.Cms.Model
{
    public class Order : CmsObject, IOrder
    {
        #region IOrder Members

        public long CustomerID
        {
            get
            {
                return Author;
            }
            set
            {
                Author = value;
            }
        }

        public string Code
        {
            get
            {
                return (string)GetExtPropertyValue("Code");
            }
            set
            {
                SetExtPropertyValue("Code", value);

            }
        }

        public DateTime OrderCreated
        {
            get
            {
                return Convert.ToDateTime(GetExtPropertyValue("OrderCreated"));
            }
            set
            {
                SetExtPropertyValue("OrderCreated", value);

            }
        }

        public DateTime OrderLastUpdated
        {
            get
            {
                return Convert.ToDateTime(GetExtPropertyValue("OrderLastUpdated"));
            }
            set
            {
                SetExtPropertyValue("OrderLastUpdated", value);

            }
        }

        public string ShippingAddress1
        {
            get
            {
                return (string)GetExtPropertyValue("ShippingAddress1");
            }
            set
            {
                SetExtPropertyValue("ShippingAddress1", value);

            }
        }

        public string ShippingAddress2
        {
            get
            {
                return (string)GetExtPropertyValue("ShippingAddress2");
            }
            set
            {
                SetExtPropertyValue("ShippingAddress2", value);

            }
        }

        public string ShippingCountry
        {
            get
            {
                return (string)GetExtPropertyValue("ShippingCountry");
            }
            set
            {
                SetExtPropertyValue("ShippingCountry", value);

            }
        }

        public string ShippingState
        {
            get
            {
                return (string)GetExtPropertyValue("ShippingState");
            }
            set
            {
                SetExtPropertyValue("ShippingState", value);

            }
        }

        public string ShippingCity
        {
            get
            {
                return (string)GetExtPropertyValue("ShippingCity");
            }
            set
            {
                SetExtPropertyValue("ShippingCity", value);

            }
        }

        public OrderStatus OrderStatus
        {
            get
            {
                return (OrderStatus)Enum.Parse(typeof(OrderStatus), GetExtPropertyValue("OrderStatus").ToString());
            }
            set
            {
                SetExtPropertyValue("OrderStatus", value);
            }
        }

        public string OrderComments
        {
            get
            {
                return (string)GetExtPropertyValue("OrderComments");
            }
            set
            {
                SetExtPropertyValue("OrderComments", value);

            }
        }

        public short Tax
        {
            get
            {
                return Convert.ToInt16(GetExtPropertyValue("Tax"));
            }
            set
            {
                SetExtPropertyValue("Tax", value);
            }
        }

        public double Total
        {
            get
            {
                double _Total = 0;
                foreach (OrderLine oL in OrderLineList)
                {
                    _Total += oL.Total;
                }
                return _Total;
            }
            
        }

        private OrderLineList _OrderLineList = new OrderLineList();
        public OrderLineList OrderLineList
        {
            get
            {
                return _OrderLineList;
            }
            set
            {
                _OrderLineList = value;
            }
        }

        #endregion
    }
}
